"""The application's model objects"""
import sqlalchemy as sa
from sqlalchemy import orm

from hellopylons.model import meta

def init_model(engine):
    """Call me before using any of the tables or classes in the model"""
    ## Reflected tables must be defined and mapped here
    #global reflected_table
    #reflected_table = sa.Table("Reflected", meta.metadata, autoload=True,
    #                           autoload_with=engine)
    #orm.mapper(Reflected, reflected_table)
    #
    meta.Session.configure(bind=engine)
    meta.engine = engine

#    Middle = sa.Table('tblmiddle', meta.metadata, 
#                      sa.Column('PK_MiddleID', sa.types.Integer, primary_key=True),
#                      sa.Column('FK_RightID', sa.types.Integer, sa.ForeignKey('Right.PK_RightID')),
#                      sa.Column('FK_LeftID', sa.types.Integer, sa.ForeignKey('Left.FK_LeftID'))
#                      )
## Non-reflected tables may be defined and mapped at module level
#foo_table = sa.Table("Foo", meta.metadata,
#    sa.Column("id", sa.types.Integer, primary_key=True),
#    sa.Column("bar", sa.types.String(255), nullable=False),
#    )
#
#class Foo(object):
#    pass
#
#orm.mapper(Foo, foo_table)
#tblUser = sa.Table("tbluser", meta.metadata,
#    sa.Column("PK_UserID", sa.types.Integer, primary_key=True),
#    sa.Column("UserName", sa.types.String, nullable=True),
#    sa.Column("Password", sa.types.String, nullable=True),
#    sa.Column("FK_UserTypeID", sa.types.Integer, nullable=True),
#    sa.Column("IsOnline", sa.types.Boolean, nullable=True),
#    sa.Column("SessionID", sa.types.String, nullable=True),
#    sa.Column("LanguageType", sa.types.String, nullable=True),
#    sa.Column("LastLoginTime", sa.types.DateTime, nullable=True),
#    sa.Column("CreateTime", sa.types.DateTime, nullable=True),
#                    )

#tblUserType = sa.Table("tblusertype", meta.metadata,
#    sa.Column("PK_UserTpyeID", sa.types.Integer, primary_key=True),
#    sa.Column("UserTypeName", sa.types.String, nullable=True),
#    sa.Column("Remark", sa.types.String, nullable=True),
#    sa.Column("CreateTime", sa.types.DateTime, nullable=True),
#                       )
## Classes for reflected tables may be defined here, but the table and
## mapping itself must be done in the init_model function
#reflected_table = None
#
#class Reflected(object):
#    pass

#class User(object):
#    pass
#class UserType(object):
#    pass

#orm.mapper(User, tblUser)
#orm.mapper(UserType, tblUserType)
